/*
 * Copyright 2016 SoChishun.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package m.lang;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import v.main.FrmMain;

/**
 * 语言模型类
 *
 * @author SoChishun
 * @version 1.0 2016-6-9
 */
public class LangModels {

    /**
     * 获取语言列表
     *
     * @return
     * @since 1.0 2016-6-9 SoChishun Added.
     */
    public static ArrayList getLangs() {
        ArrayList<HashMap> langs = new ArrayList<HashMap>();
        HashMap lang = new HashMap();
        lang.put("id", "zh_CN");
        lang.put("text", "简体中文");
        langs.add(lang);
        lang = new HashMap();
        lang.put("id", "en_US");
        lang.put("text", "English");
        langs.add(lang);
        return langs;
    }

    static ResourceBundle langBundle;
    /**
     * 获取语言包的值
     * @param key
     * @return 
     * @since 1.0 2016-6-9 SoChishun Added.
     */
    public static String getString(String key){
        return langBundle.getString(key);
    }

    /**
     * 根据指定的国家/语言环境加载对应的语言资源文件
     * <p>
     * setLocale(new Locale("zh_CN"));<br />
     * setLocale(Locale.getDefault());
     * </p>
     *
     * @param locale
     * @since 1.0 2016-5-27
     */
    public static void setLocale(Locale locale) {
        // Locale locale = Locale.getDefault();//获得系统默认的国家/语言环境 new Locale("en_US")
        langBundle = ResourceBundle.getBundle("res.message", locale);//根据指定的国家/语言环境加载对应的资源文件
    }
}
